﻿using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace SharePointAccelerators.ApplyTheme.ApplyThemeEventReceiver
{
    /// <summary>
    /// Web Events
    /// </summary>
    public class ApplyThemeEventReceiver : SPWebEventReceiver
    {
       /// <summary>
       /// A site was provisioned.
       /// </summary>
       public override void WebProvisioned(SPWebEventProperties properties)
       {
           ThmxTheme theme = ThmxTheme.Open(properties.Web.Site, ThmxTheme.GetThemeUrlForWeb(properties.Web.ParentWeb));
           theme.ApplyTo(properties.Web, false);
           properties.Web.Update();

           base.WebProvisioned(properties);
       }
    }
}
